package com.yanqu.road.server.cmd.task;

import com.yanqu.road.pb.task.TaskProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

@Cmd(code = Protocol.S_TASK_GET_SEVEN_DAY_ACTIVE_REWARD, desc = "领取七日活跃度奖励")
public class GetSevenDayActiveRewardCmd extends AbstractCommand {

	int taskActive;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		TaskProto.TaskActiveRewardReqMsg reqMsg = TaskProto.TaskActiveRewardReqMsg.parseFrom(packet.getBytes());
		taskActive = reqMsg.getTaskActive();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = player.getModule(TaskModule.class).getSevenDayActiveReward(taskActive);
	}

	@Override
	public void sendData(GamePlayer player) {
		TaskProto.TaskActiveRewardRespMsg.Builder respMsg = TaskProto.TaskActiveRewardRespMsg.newBuilder();
		respMsg.setRet(ret);
		player.sendPacket(Protocol.U_TASK_GET_SEVEN_DAY_ACTIVE_REWARD, respMsg);
	}

}
